package ${entity.entityPackageName};

import javax.persistence.*;
<#if entity.hasSetType>
import java.util.Set;
</#if>
<#if entity.hasDateType>
import java.util.Date;
</#if>
<#if entity.hasDecimalType>
import java.math.BigDecimal;
</#if>
import ${entity.entityPackageName}.${entity.className};
<#list entity.sPropList as sprop>
import ${entity.entityPackageName}.${sprop.foreignClassName};
</#list>
<#list entity.aPropList as aprop>
import ${entity.entityPackageName}.${aprop.primaryClassName};
</#list>

/**
 * 表${entity.tableName}对应的Entity实体基类
 * 自动生成代码，请勿更改
 */
@Table(name = "${entity.tableName}")
public  class ${entity.className} {
	/**
	 * 主键
	 */
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	protected ${entity.idSimpleType} ${entity.idName};
<#if entity.hasHibernateVersion>
	/**
	 * 对象版本，hibernate使用
	 */
	protected Integer hibernateVersion;
</#if>

<#list entity.propList as prop>
	/**
	 * ${prop.note}
	 */
	protected ${prop.simpleType} ${prop.propName};
</#list>

<#list entity.aPropList as aprop>
	/**
	 * 
	 */
	protected ${aprop.primaryClassName} ${aprop.propName};
</#list>

<#list entity.sPropList as sprop>
	/**
	 *
	 */
	protected Set<${sprop.foreignClassName}> ${sprop.propName};
</#list>

	/**
	 * 主键
	 */
	public ${entity.idSimpleType} ${entity.idGetMethod}() {
		return ${entity.idName};
	}
	/**
	 * 主键
	 */
	public void ${entity.idSetMethod}(${entity.idSimpleType} ${entity.idName}) {
		this.${entity.idName} = ${entity.idName};
	}
<#if entity.hasHibernateVersion>
	@JsonIgnore
	public Integer getHibernateVersion() {
		return hibernateVersion;
	}
	public void setHibernateVersion(Integer hibernateVersion) {
		this.hibernateVersion = hibernateVersion;
	}
</#if>
<#list entity.propList as prop>
	/**
	 * ${prop.note}
	 */
	public ${prop.simpleType} ${prop.getMethod}() {
		return ${prop.propName};
	}
	/**
	 * ${prop.note}
	 */
	public void ${prop.setMethod}(${prop.simpleType} ${prop.propName}) {
		this.${prop.propName} = ${prop.propName};
	}
	
</#list>
<#list entity.aPropList as aprop>
	/**
	 * 
	 */
	@JsonIgnore
	public ${aprop.primaryClassName} ${aprop.getMethod}() {
		return this.${aprop.propName};
	}
	/**
	 * 
	 */
	public void ${aprop.setMethod}(${aprop.primaryClassName} ${aprop.propName}) {
		this.${aprop.propName} = ${aprop.propName};
	}
</#list>
<#list entity.sPropList as sprop>
	/**
	 *
	 */
	@JsonIgnore
	public Set<${sprop.foreignClassName}> ${sprop.getMethod}() {
		return ${sprop.propName};
	}
	/**
	 *
	 */
	public void ${sprop.setMethod}(Set<${sprop.foreignClassName}> ${sprop.propName}) {
		this.${sprop.propName} = ${sprop.propName};
	}
</#list>

	public ${entity.className} clone() {
		${entity.className} instance = new ${entity.className}();
		instance.${entity.idSetMethod}(this.${entity.idName});
<#list entity.propList as prop>
		instance.${prop.setMethod}(this.${prop.propName});
</#list>
		return instance;
	}
	
	public String toJsonString() {
		StringBuffer sb = new StringBuffer("{");
		sb.append("\"${entity.idName}\":\"").append(this.${entity.idName}).append("\"");
<#list entity.propList as prop>
		sb.append(",\"${prop.propName}\":\"").append(this.${prop.propName}).append("\"");
</#list>
<#list entity.aPropList as aprop>
		sb.append(",\"${aprop.propName}\":\"").append(this.${aprop.propName}).append("\"");
</#list>
		sb.append("}");
		return sb.toString();
	}
	
	@Override
	public String toString() {
		return this.toJsonString();
	}

	public final static String _${entity.idName} = "${entity.idName}";
<#list entity.propList as prop>
	public final static String _${prop.propName} = "${prop.propName}";
</#list>
}